//
//  Student.m
//  P1111
//
//  Created by 闫潇 on 14/11/11.
//  Copyright (c) 2014年 yan. All rights reserved.
//

#import "Student.h"

@implementation Student
-(void)setName:(NSString *)aName
{
    name=aName;
}
-(NSString *)name
{
    return name;
}
-(void)setAge:(int)anAge
{
    if (anAge<0) {
        NSLog(@"岁数不合适,呵呵!");
        age = 18;
    }
    else{
        age = anAge;
    }
}
-(int)age
{
    return age;
}
-(NSString *)description
{
    return [NSString stringWithFormat:@"我叫%@，我今年%d岁了！",self->name,self->age];
    
}
-(NSComparisonResult)myCompare:(id)anObject
{//以名字来排序
//    NSComparisonResult result = [[self name]
//                                 compare:[anObject name]];
//    return result;
    return [[self name] compare:[anObject name]];
    //等价于上面两句
}
@end
